import { Base } from '../../utils/base.js';

class Jqdetail extends Base {
  constructor() {
    super();
  } //查询姓名手机号避免填写


  getinfo(callBack) {
    var params = {
      url: 'getinfo',
      sCallBack: function (res) {
        callBack && callBack(res);
      }
    };
    this.request(params);
  } //缺货登记


  getquehuo(aid, phone, quehuo_num, word, priceid, callBack) {
    var param = {
      url: 'quehuo_Jq?aid=' + aid + '&phone=' + phone + '&quehuo_num=' + quehuo_num + '&word=' + word + '&priceid=' + priceid,
      sCallBack: function (data) {
        callBack && callBack(data);
      }
    };
    this.request(param);
  } //用户标识


  getuser_logo(callBack) {
    var param = {
      url: 'getuser_logo',
      sCallBack: function (data) {
        callBack && callBack(data);
      }
    };
    this.request(param);
  } 

  //小程序码
  get_qr_code(id, mid, _page, callBack) {
    var param = {
      url: 'SmallProgramCodeDistribution?id=' + id + '&mid=' + mid + '&page=' + _page,
      sCallBack: function (data) {
        callBack && callBack(data);
      }
    };
    this.request(param);
  }

  get_qr_code(id, mid, _page, callBack) {
    var access_token = ''
    tt.request({
      url: 'https://developer.toutiao.com/api/apps/token?appid=tt31d3476eaee9295c&secret=082980c45f34ca696b71c7656b80c3e8db038a00&grant_type=client_credential', // 目标服务器url
      success: (res) => {
        console.log('123', res.data)
        access_token = res.data.access_token
        tt.request({
          url: 'https://developer.toutiao.com/api/apps/qrcode', // 目标服务器url
          method: 'POST',
          responseType: 'arraybuffer',//响应方式
          data: {
            "access_token": res.data.access_token,
            "appname": "douyin",
            "path": "pages/jqdetail/jqdetail?id="+id,
            "width": 280,
          },
          success: (res) => {
            let qrImg = "data:image/png;base64," + tt.arrayBufferToBase64(res.data)
            console.log(qrImg);
            callBack && callBack(qrImg);
          }
        });
      }
    });
  }


  JqdetailFor(id, callBack) {
    var param = {
      url: 'JqdetailFor?id=' + id,
      sCallBack: function (data) {
        callBack && callBack(data);
      }
    };
    this.request(param);
  }

  getAnswers(id, callBack) {
    var param = {
      url: 'getAnswers?aid=' + id + '&count=5',
      sCallBack: function (data) {
        callBack && callBack(data);
      }
    };
    this.request(param);
  }

  getCommodity(id, callBack) {
    var param = {
      url: 'getCommodity?aid=' + id,
      sCallBack: function (data) {
        callBack && callBack(data);
      }
    };
    this.request(param);
  } 
  
  //景区价格有pricestyle
  getJQdetail(id, callBack) {
    var param = {
      url: 'getJQdetail?aid=' + id,
      sCallBack: function (data) {
        callBack && callBack(data);
      }
    };
    this.request(param);
  } //景区价格没有pricestyle


  getJQdetail2(id, callBack) {
    var param = {
      url: 'getJQdetail2?aid=' + id,
      sCallBack: function (data) {
        callBack && callBack(data);
      }
    };
    this.request(param);
  } //景区价格内部详情信息


  getJQdetail3(pricestyle, id, callBack) {
    var param = {
      url: 'getJQdetail3?pricestyle=' + pricestyle + '&aid=' + id,
      sCallBack: function (data) {
        callBack && callBack(data);
      }
    };
    this.request(param);
  }

  getJQListArr(id, callBack) {
    var param = {
      url: 'getJQListArr?aid=' + id,
      sCallBack: function (data) {
        callBack && callBack(data);
      }
    };
    this.request(param);
  }

  getJQListArr2(id, callBack) {
    var param = {
      url: 'getJQListArr2?aid=' + id,
      sCallBack: function (data) {
        callBack && callBack(data);
      }
    };
    this.request(param);
  }

}

export { Jqdetail };